package com.ihr360.insurance.controller.benefit;

import com.ihr360.insurance.model.dto.benefits.MandatoryBenefitTemplate;
import com.ihr360.insurance.service.MandatoryBenefitTemplateService;
import com.ihr360.maven.plugin.ModuleCodeStore;
import com.ihr360.maven.plugin.annotation.FunctionDefinition;
import com.ihr360.maven.plugin.annotation.ModuleDefinition;
import com.ihr360.rest.service.SimpleRestService;
import com.ihr360.rest.webmvc.AbstractRestSimpleWithLongIdController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author david.wei
 */
@RestController
@RequestMapping("/mandatoryBenefitTemplates")
@ModuleDefinition(mainModuleCode = ModuleCodeStore.Module.BENEFIT_CODE_ADMIN,
        mainModuleName = ModuleCodeStore.Module.BENEFIT_NAME_ADMIN,
        subModuleCode = ModuleCodeStore.Module.BenefitAdmin.SI_GROUP_ADMIN_CODE,
        subModuleName = ModuleCodeStore.Module.BenefitAdmin.SI_GROUP_ADMIN_NAME,
        hasExtendsAbstractRestController = true)
public class MandatoryBenefitTemplateController extends AbstractRestSimpleWithLongIdController<MandatoryBenefitTemplate> {
    @Autowired
    MandatoryBenefitTemplateService benefitTemplateService;

    @Override
    public SimpleRestService getSimpleRestService() {
        return benefitTemplateService;
    }

    @FunctionDefinition(functionName = "更新模板数据", functionCode = ModuleCodeStore.Function.UPDATE)
    @ApiOperation(value = "更新模板数据，包括模板里面的缴纳数据")
    @PostMapping(value = "/update")
    public boolean updateBenefit(@RequestBody MandatoryBenefitTemplate template) {
        benefitTemplateService.updateBenefit(template);
        return true;
    }

}